//重置样式
require('../../assets/css/index.less')

//引入weui库
require('../../assets/lib/weui/weui.css')
let weui = require('../../assets/lib/weui/weui.js')
console.log(weui);

//当前页面样式
require('./introduce.less')

//引入字体库
require('../../assets/fonts/iconfont.css')

//引入dom
const dom = require('../../utils/dom.js')

//引入https
const https = require('../../utils/https.js')




dom.reday(function () {

    //回到上一页
    dom.getEvent('#comeBack', function () {
        history.go(-1)
    })

    // 获取id
    let id = location.search.slice(location.search.indexOf('=') + 1)
    console.log(id);
    //获取值
    https.get('/api/train/courseDetail?id=' + id, function (res) {
        let { errno, data } = res
        console.log(res);
        if(errno==0){
            //视频添加
            dom.getEle('#myVideo').src=https.BASE_URL+data.fragments[0].videoUrl
            dom.getEle('#title').textContent=data.name
            dom.getEle('#calorie').textContent=data.calorie
            dom.getEle('#time').textContent=data.time
            dom.getEle('#desc').textContent=data.desc

        }
    })


    //点击训练
    let flag = true
    dom.getEvent('#start',function(){
        // location.href='startTraining.html?id='+id
        if(flag){
            dom.getEle('#myVideo').play()
            dom.getEle('#start').textContent='暂停'
        }else{
            dom.getEle('#myVideo').pause()
            dom.getEle('#start').textContent='继续'
        }
        flag =! flag
    })
})